#![allow(unused_imports,unused_assignments)]
use serde::{Deserialize, Serialize};
use sqlx::mysql::MySqlRow;
use sqlx::{FromRow, Row};
use sqlx::Error;
use crate::domain::count_num::get_i64;
use crate::domain::count_num::get_i32;
use crate::domain::count_num::get_f64;
use crate::domain::count_num::get_f32;
use crate::domain::count_num::get_bool;
use crate::domain::count_num::get_string;
use crate::domain::count_num::get_dropdown;

#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(rename_all = "camelCase")]
pub struct GoodsTypeBean {
	pub id: i64,
	pub name: String,
	pub active: bool,
}

#[derive(Serialize, Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct GoodsTypeQueryRequest {
	pub id: Option<String>,
	pub name: Option<String>,
	pub active: Option<String>,
	pub page:Option<i32>,
	pub rows:Option<i32>,
}

impl<'c> FromRow<'c, MySqlRow> for GoodsTypeBean {
	fn from_row(row: &MySqlRow) -> Result<Self, Error> {
		Ok(GoodsTypeBean {
			id: row.get(0),
			name: row.get(1),
			active: row.get(2),
		})
	}
}

impl PartialEq for GoodsTypeBean {
	fn eq(&self, other: &Self) -> bool {
		self.id == other.id
	}
}
